<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
    <xsl:param name="DOTNET2"/>
    

  
	<xsl:template match="Class">
		<xsl:variable name="Name" select="Name"/>
        <xsl:variable name="HeaderInfo" select="HeaderInfo/ProjectName"/>



// **************************************************************
// COUCH DB <xsl:value-of select="Name"/> CLASS
// Project Name: <xsl:value-of select="HeaderInfo/ProjectName"/>
// Prefix: <xsl:value-of select="HeaderInfo/Prefix"/>
// **************************************************************

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using NUnit.Framework;

namespace <xsl:value-of select="HeaderInfo/ProjectName"/>.UnitTest  {


	public class <xsl:value-of select="Name"/> 
	{

			
		public static DataObject.<xsl:value-of select="Name"/> PopulateObj ( )
		{
			DataObject.<xsl:value-of select="Name"/> obj = new DataObject.<xsl:value-of select="Name"/> ( );
			<xsl:for-each select="ClassAttribs/ClassAttributes">
				<xsl:if test="KnownClass='false' and CType='single'">
			obj.<xsl:value-of select="PropertyName"/> = TestSetup.<xsl:value-of select="Type"/>TestVal;</xsl:if>
				<xsl:if test="KnownClass='false' and CType!='single'">
			obj.<xsl:value-of select="PropertyName"/> = TestSetup.<xsl:value-of select="Type"/>TestValArray;</xsl:if>
				<xsl:if test="KnownClass='true' and CType='single'">
			obj.<xsl:value-of select="PropertyName"/> = <xsl:value-of select="Type"/>.PopulateObj ( );	
				</xsl:if>
				<xsl:if test="KnownClass='true' and CType!='single'">
			obj.<xsl:value-of select="PropertyName"/> = new DataObject.<xsl:value-of select="Type"/>[] { <xsl:value-of select="Type"/>.PopulateObj ( ), <xsl:value-of select="Type"/>.PopulateObj ( ) };
				</xsl:if>
			</xsl:for-each>

			return obj;
		}
		
		public static void VerifyObj ( DataObject.<xsl:value-of select="Name"/> obj )
		{
			<xsl:for-each select="ClassAttribs/ClassAttributes">
				<xsl:if test="KnownClass='false' and CType='single'">
			Assert.IsTrue ( obj.<xsl:value-of select="PropertyName"/>.Equals ( TestSetup.<xsl:value-of select="Type"/>TestVal ) );</xsl:if>
				<xsl:if test="KnownClass='false' and CType!='single'">
			Assert.IsTrue ( obj.<xsl:value-of select="PropertyName"/> [ 1 ].Equals ( TestSetup.<xsl:value-of select="Type"/>TestValArray [ 1 ] ) );</xsl:if>
				<xsl:if test="KnownClass='true' and CType!='single'">
			
			<xsl:value-of select="Type"/>.VerifyObj ( obj.<xsl:value-of select="PropertyName"/> [ 1 ] );
				</xsl:if>
			</xsl:for-each>
		}
		
	
		[Test]
		public void TestCreateDelete ( )
		{
			DataObject.<xsl:value-of select="Name"/> obj = PopulateObj ( );

			obj.Save ( );
			obj.Delete ( true );
		
		}
		
		
		[Test]
		public void TestCreateReadDelete ( )
		{
		
			DataObject.<xsl:value-of select="Name"/> obj = PopulateObj ( );
			obj.Save ( );
			
			obj = new DataObject.<xsl:value-of select="Name"/> ( ).Load ( obj._docid );
			VerifyObj ( obj );

			obj.Delete ( true );
			
		}
		
		[Test]
		public void TestMethods ( )
		{

			DataObject.<xsl:value-of select="Name"/> obj = PopulateObj ( );
			obj.Save ( );
			
			<xsl:for-each select="ClassAttribs/ClassAttributes">
				<xsl:if test="CType='single' and KnownClass='false'">
			Assert.IsTrue ( DataObject.<xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/> ( TestSetup.<xsl:value-of select="Type"/>TestVal ) [ 0 ].<xsl:value-of select="PropertyName"/>.Equals ( TestSetup.<xsl:value-of select="Type"/>TestVal ) );
				</xsl:if>
				
				<xsl:if test="CType='single' and KnownClass='true'">
			Assert.IsTrue ( DataObject.<xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/> ( obj.<xsl:value-of select="PropertyName"/> ).Length == 1 );
				</xsl:if>
			</xsl:for-each>
			
			obj.Delete ( true );

		}
		
		
	
	}


}

	</xsl:template>
</xsl:stylesheet>